package cn.jsu.oj.dispatchServer.satellite.util;

import java.util.Base64;
import java.util.UUID;

/**
 * 压缩工具
 *
 * @author shan
 * @date 2022/07/04
 */
public class CompressUtil {

    public static String compress(String src) {
        UUID uuid = UUID.fromString(src);
        long msb = uuid.getMostSignificantBits();
        long lsb = uuid.getLeastSignificantBits();
        byte[] b = new byte[16];
        for (int i = 0; i < 8; i++) {
            b[i] = (byte) (msb >>> (8 * (7 - i)) & 0xff);
            b[i + 8] = (byte) (lsb >>> (8 * (7 - i)) & 0xff);
        }
        return Base64.getEncoder().withoutPadding().encodeToString(b);
    }
}
